﻿/**
 *
 * @title: Basic MVC Framework, AbstractModel Class
 * @author: Robert Turrall (http://www.robertturrall.com)
 * @license: Creative Commons Attribution 3.0 (http://creativecommons.org/licenses/by/3.0/)
 *			In other words: Please feel free to use, change, redistribute and do what you want with 
 *			this code. Just keep the original header and author attribution intact. Follow the license
 *			link for more info.
 * @updated: 31/12/2008
 *
 * @version	1.0 
 */

package net.turrall.mvc {
	
	import net.turrall.mvc.*;
	import flash.events.EventDispatcher;
	import flash.events.Event;

	/**
	 * Basic Model class in Model/View/Controller triad.
	 */
	public class AbstractModel extends EventDispatcher {	
	
		public static const UPDATE:String = "modelUpdated";
		
		public function AbstractModel()  {
			// empty
		}
		
		/**
		 * This method will cause an update event and object
		 * to be passed up to the view. Using CustomEvent allows
		 * a data object to be passed along with the event
		 */
		public function onUpdate(ob:Object):void {
			var e:CustomEvent = new CustomEvent(AbstractModel.UPDATE, true, false, ob);
			dispatchEvent(e);
		}
	}
}